﻿using System;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.Collections.Generic;
using System.Reflection;
namespace Data
{
	 	//MsgSendInfo
    public class MsgSendInfo
	{
            private DataAccess Access = new Data.DataAccess();
		/// <summary>
        /// 主键
        /// </summary>
        private readonly string primaryKey= "Id";
		/// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public long Add(Model.MsgSendInfo model)
        {
            return Access.Add<Model.MsgSendInfo>(model, primaryKey);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Update(Model.MsgSendInfo model)
        {
            return Access.Update<Model.MsgSendInfo>(model, primaryKey);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public bool Delete(long Id)
        {
            return Access.Delete<Model.MsgSendInfo>(Id, primaryKey);
        }
        /// <summary>
        /// 单条
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public Model.MsgSendInfo GetModel(long Id)
        {
            return Access.Get<Model.MsgSendInfo>(Id, primaryKey);
        }
        public Model.MsgSendInfo GetModelOrderByAddtime(int type, string userPhone)
        {
            System.Data.Common.DbParameter[] p = new System.Data.Common.DbParameter[0];
            StringBuilder sqlWhere = new StringBuilder();
            sqlWhere.Append("msgType=" + type + " and mobel='" + userPhone + "' order by addTime desc");
            return Access.Get<Model.MsgSendInfo>(sqlWhere.ToString(), p);
        }
        public Model.MsgSendInfo GetModelAll(string sql)
        {
            System.Data.Common.DbParameter[] p = new System.Data.Common.DbParameter[0];
            StringBuilder sqlWhere = new StringBuilder();
            sqlWhere.Append(sql+"  order by addTime desc");
            return Access.Get<Model.MsgSendInfo>(sqlWhere.ToString(), p);
        }
	}
}